<template>
  <yy-paging v-model="dataList" @query="queryList" ref="paging" :auto="automatic" @scroll="scroll" :refresher-enabled="false">
    <template #top>
      <u-navbar
        back-text="返回"
        :is-back="false"
        :background="{ backgroundColor: isScroll ? '#FFFFFF' : 'transparent' }"
        :border-bottom="false"
        :custom-style="{ transition: 'background-color 0.3s ease-in-out' }"
      >
      </u-navbar>
    </template>
    <view class="p-4"> </view>
  </yy-paging>
</template>

<script>
  export default {
    data() {
      return {
        isScroll: false,
        dataList: [],
        automatic: false
      }
    },
    async onLoad(options) {
      let res = await vk.myfn.login().catch(err => {
        console.log('err==> ', err)
        console.log('err==> ', err.code)
        console.log('err==> ', err.code)
        if (err.code == 30003) {
          vk.redirectTo('/pages/index/index')
          return
        }
        // 30002 其他
        if (err.code == 30002) {
          vk.redirectTo('/pages/login/index')
          return
        }
        vk.redirectTo('/pages/login/index')

        // 30008
      })
      if (!res) return
      vk.callFunction({
        url: 'client/pub.index.oneClickLogin',
        title: '请求中...',
        data: {
          access_token: res.authResult.access_token,
          openid: res.authResult.openid
        },
        success: data => {
          vk.toast(`${data.data.phoneNumber},登录成功！！`)
        }
      })
    },
    methods: {
      scroll(e) {
        this.isScroll = e.detail.scrollTop > 0
      },
      async queryList(page, limit) {
        this.$refs.paging.complete([1, 1, 1])
      }
    }
  }
</script>

<style lang="scss" scoped></style>
